package shiyan1;

import java.util.Scanner;

public class JieGouHua {
    public static void main(String[] args) {
        System.out.println("1:圆");
        System.out.println("2:正方形");
        System.out.println("3:矩形");
        System.out.println("4:椭圆");
        System.out.println("exit:退出");

        while(true)
        {
            Scanner sc=new Scanner(System.in);
            String s=sc.next();
            if(s.equals("exit")){
                break;
            }
            calS(s);

        }
    }
    public static void calS(String s)
    {
        switch (s)
        {
            case "1":circle();break;
            case "2":zhengfangxing();break;
            case "3":juxing();break;
            case "4":tuoyuan();break;
            default: throw new RuntimeException("错误");
        }
    }
    public static void circle()
    {
        System.out.println("输入圆半径：");
        Scanner sc=new Scanner(System.in);
        System.out.println("面积为:"+Math.pow(sc.nextInt(),2)*3.14);
    }
    public static void zhengfangxing()
    {
        System.out.println("输入正方形边长:");
        Scanner sc=new Scanner(System.in);
        System.out.println("面积为"+Math.pow(sc.nextInt(),2));
    }
    public static void juxing()
    {
        System.out.println("输入矩形的长宽：");
        Scanner sc=new Scanner(System.in);
        System.out.println("面积为："+sc.nextInt()*sc.nextInt());
    }
    public static void tuoyuan()
    {
        System.out.println("输入椭圆的长短半轴：");
        Scanner sc=new Scanner(System.in);
        System.out.println("面积为："+sc.nextInt()*sc.nextInt()*3.14);
    }
}
